# 1.已知字典 dic = {'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}，实现以下功能
dic = {'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}

# a.遍历字典 dic 中所有的key
for key in dic.keys():
    print(key)
print("="* 50)
# b.遍历字典 dic 中所有的value
for value in dic.values():
    print(value)
print("=" * 50)
# c.循环遍历字典 dic 中所有的key和value
for key,value in dic.items():
    print(key,value)
print("=" * 50)
# d.添加一个键值对"k4","v4",输出添加后的字典 dic
dic["k4"]="v4"
print(dic)
print("=" * 50)
# e.删除字典 dic 中的键值对"k1","v1",并输出删除后的字典 dic
del dic["k1"]
print(dic)
print("=" * 50)
# f.删除字典 dic 中 'k5' 对应的值，若不存在，使其不报错，并返回None
if "k5" not in dic:
    print(None)
else:
    del dic["k5"]
print("=" * 50)
# g.获取字典 dic 中'k2'对应的值
print(dic["k2"])
print("=" * 50)

# h.已知字典dic2 = {'k1':"v111",'a':"b"} 编写程序，使得dic2 = {'k1':"v111",'k2':"v2",'k3':"v3",'a':"b"}
dic2 = {'k1':"v111",'a':"b"}
dic2.update(dic)
print(dic2)
